# example-1
# Illustrates creating an instance of uhferret and 
# finding the similarity of some sample documents.

require "uhferret"

# Construct an instance of ferret and add some documents to it.
ferret = UHFerret::Ferret.new
ferret.add "text-eg/ruby.txt"
ferret.add "text-eg/cobra.txt"
ferret.add "text-eg/fantom.txt"

# Run ferret to compute similarities.
# This step can take a long time, if there are many documents.
ferret.run

# Print out information for every document.
ferret.each do |doc|
  puts "Document name: #{doc.filename}"
end

# Print out some information for every pair of documents.
ferret.each_pair do |i, j|
  puts "For document #{i} - #{ferret[i].filename}"
  puts "and document #{j} - #{ferret[j].filename}"
  puts "Resemblance is #{ferret.resemblance(i, j)}"
  puts "Containment of #{i} in #{j} is #{ferret.containment(i, j)}"
  puts "Containment of #{j} in #{i} is #{ferret.containment(j, i)}"
  puts "Doc #{i} has #{ferret.trigram_count(i)} trigrams, \
doc #{j} has #{ferret.trigram_count(j)} trigrams, and \
they share #{ferret.trigram_matches(i, j)} trigrams"
end

